package com.yonyou.pmclouds.organization.rmiimpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.yonyou.pmclouds.ApplicationConsts;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.util.SqlUtil;
import com.yonyou.pmclouds.organization.entity.OrgAndRoleVO;
import com.yonyou.pmclouds.organization.mapper.OrgAndRoleMapper;
import com.yonyou.pmclouds.organization.rmiitf.OrgAndRoleQuery;
import org.springframework.beans.factory.annotation.Autowired;

@Service(version = ApplicationConsts.APPLICATION_VERSION, interfaceClass= OrgAndRoleQuery.class)
public class OrgAndRoleQueryImpl implements OrgAndRoleQuery{
    @Autowired
    private OrgAndRoleMapper roleMapper;

    @Override
    public OrgAndRoleVO[] queryRoleList(String pkTenant) throws BusinessException {
        return roleMapper.getRoleList(pkTenant);
    }

    @Override
    public Boolean queryIsDistribute(String pkTenant, String[] pkRoles) throws BusinessException {
        return roleMapper.countTenantRole(pkTenant, SqlUtil.getSqlIn(pkRoles)) > 0;
    }

    @Override
    public OrgAndRoleVO[] queryListByOrg(String pkTenant, String pkOrganization) throws BusinessException {
        return roleMapper.getListByOrg(pkTenant,pkOrganization);
    }
}
